package com.xiao.mall.foundation.errors;

import org.zalando.problem.AbstractThrowableProblem;
import org.zalando.problem.Status;

public class InvalidOperationException extends AbstractThrowableProblem {

    private final static String DEFAULT_MESSAGE = "操作无效，当前状态下不能进行此操作。";
    private final static String DETAIL_MESSAGE = "操作无效，当前状态为%s, 操作为%s。";
    private static final long serialVersionUID = 1L;

    private final String status;
    private final String operation;

    public InvalidOperationException(String status, String operation) {
        this(DETAIL_MESSAGE, status, operation);
    }

    public InvalidOperationException(String message, String status, String operation) {
        super(ErrorConstants.DEFAULT_TYPE, message,
                Status.BAD_REQUEST,
                String.format(DETAIL_MESSAGE, status, operation), null, null);
        this.status = status;
        this.operation = operation;
    }
}
